import 'package:flutter/material.dart';
import 'package:lz_app_core/constants/app_manager.dart';
import 'package:lz_app_core/enum/app_enum.dart';
import 'package:lz_app_core/kd_user/kd_user_info.dart';
import 'package:lz_ui/kd_ui.dart';

import '../serve/kd_login_api.dart';



class KDCancellationPage extends StatefulWidget {
  const KDCancellationPage({super.key});

  @override
  State<KDCancellationPage> createState() => _KDCancellationPageState();
}

class _KDCancellationPageState extends State<KDCancellationPage> {
  @override
  Widget build(BuildContext context) {
    return KDScaffold.scaffold(
        title: "注销账号",
        body: Column(
          children: [
            const SizedBox(height: 24),
            const Text(
              "注销须知",
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
            ),
            const SizedBox(height: 2),
            Text(
              "账号注销后，将放弃以下权益和资产",
              style: TextStyle(
                fontSize: 14,
                color: KDColor.subTitle,
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: const EdgeInsets.symmetric(vertical: 24),
                    child: Text(
                      "1. 账号内个人资料、实名认证信息\n\n2. 历史运单将无法查询\n\n3. 账号将无法登录\n\n4. 放弃钱包等其他用户权益",
                      style: TextStyle(
                        fontSize: 14,
                        color: KDColor.subTitle,
                      ),
                    ),
                  ),
                  _redRow("请确保所有运单都已完结"),
                  _redRow("请确保进度钱包没有余额"),
                  _redRow("注销账户不代表注销前的账户行为和相关责任得到豁免或减轻"),
                ],
              ),
            ),
            const SizedBox(height: 24),
            KDButton.bottomBtn(
              title: "注销",
              textColor: KDColor.title,
              bgColor: KDColor.disInputBg,
              tap: () {

                DialogUtils.showCustomDialog(
                  title: "1.为了保证你的所有运单处于完结状态，钱包没有余额。2.账户无其他任何责任。请联系客户查询账户状态，并且注销。",
                  leftTitle: getLogOff(),
                  rightTitle: "联系客服注销",
                    onTapToCancel:getLogoffRequest,
                  onTapToOK: (){
                    KDTel.callPhone(AppManager.configModel.kfTel);
                  }
                );

              },
            )
          ],
        ));
  }

  void  getLogoffRequest() async{

      String  phone = "13248043896";
      if(KDUser.info.phone ==phone ){ //商店审核
       await KDLoginApi.mineDetailInfo();
        DialogUtils.showToast("注销已提交，等待审核");
      }

  }


  String  getLogOff(){

      if(KDUser.info.phone =="13248043896" ){ //商店审核
        return "注销";
      }else{
        return "取消";
      }

  }

  Widget _redRow(String text) {
    double radiu = 3;
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 1),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.only(top: 11),
            child: Container(
              width: radiu,
              height: radiu,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(radiu)),
                color: KDColor.errRed,
              ),
            ),
          ),
          const SizedBox(width: 3),
          Expanded(
            child: Text(
              text,
              style: TextStyle(
                fontSize: 14,
                color: KDColor.errRed,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
